package com.example.demo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class Person {
     
    @JSONField(name = "AGE", serialize = false)
    private int age;
 
    @JSONField(name = "FULL NAME", ordinal = 1)
    private String fullName;
 
    @JSONField(name = "DATE OF BIRTH", ordinal = 2, format = "dd/MM/yyyy")
    private Date dateOfBirth;
 
    public Person(int age, String fullName, Date dateOfBirth) {
        super();
        this.age = age;
        this.fullName= fullName;
        this.dateOfBirth = dateOfBirth;
    }

    public static void main(String[] args) {
        List<Person> listOfPersons = new ArrayList<>();
        listOfPersons.add(new Person(15, "John Doe", new Date()));
        listOfPersons.add(new Person(20, "Janette Doe", new Date()));

        String jsonOutput= JSON.toJSONString(listOfPersons);
        System.out.println(jsonOutput);
    }
}
